package com.wswy.wzcx.model.license;

import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import java.util.HashMap;
import java.util.Map;

public class EditCarModel implements Parcelable {


    public int carId;

    //   "01": "大型车","02": "小型车"
    public String carType = "02";


    public String province;

    public String licenseNo;
    public String engineNo;
    public String frameNo;

    public String city;

    public int areaId;


    public String getFullLicense(){
        return province+licenseNo;
    }



    public Map<String,String> convertQueryMap(){
        HashMap<String, String> hashMap = new HashMap<>();
        if(carId  >0){
            hashMap.put("carId",String.valueOf(carId));
        }
        hashMap.put("cityId", String.valueOf(areaId));
        hashMap.put("carNo", getFullLicense());
        hashMap.put("carType", carType);
        if(frameNo != null){
            hashMap.put("frameNo", frameNo.toString());
        }
        if(engineNo != null){
            hashMap.put("engineNo", engineNo.toString());
        }
        return hashMap;
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.carId);
        dest.writeString(this.carType);
        dest.writeString(this.province);
        dest.writeString(this.licenseNo);
        dest.writeString(this.engineNo);
        dest.writeString(this.frameNo);
        dest.writeString(this.city);
        dest.writeInt(this.areaId);
    }

    public EditCarModel() {
    }

    protected EditCarModel(Parcel in) {
        this.carId = in.readInt();
        this.carType = in.readString();
        this.province = in.readString();
        this.licenseNo = in.readString();
        this.engineNo = in.readString();
        this.frameNo = in.readString();
        this.city = in.readString();
        this.areaId = in.readInt();
    }

    public static final Creator<EditCarModel> CREATOR = new Creator<EditCarModel>() {
        @Override
        public EditCarModel createFromParcel(Parcel source) {
            return new EditCarModel(source);
        }

        @Override
        public EditCarModel[] newArray(int size) {
            return new EditCarModel[size];
        }
    };
}
